import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    menulists: {},
    menunews: {},
    domain: 'http://ketuo.xlhd.cn',
    domainhtml: 'http://ketuo.zounikeji.cn'
  },
  mutations: {
    menulistjson(state,data) {
      state.menulists = data;
    },
    menunewsapi(state,data) {
      state.menunews = data;
    }
  },
  getters: {
    getnewsdata: function(state){
      return JSON.stringify(state.menunews).length>100?state.menunews:false;
    },
    getmenulist: function(state){
      return JSON.stringify(state.menulists).length>100?state.menulists:false;
    },
    getmenuconfig: function(state){
      return state.menulists.config;
    },
    getmenudatalist: (state) => (id) => {
      return state.menulists.menu_list?state.menulists.menu_list[id].son:''
    },
    getmenudata: (state) => (id) => {
      return state.menulists.menu_list?state.menulists.menu_list[id]:''
    }
  },
  actions: {

  },
  modules: {
  }
})
